package com.cskaoyan.controller;

import com.cskaoyan.bean.MarketTopic;
import com.cskaoyan.bean.common.BasePageInfo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.bean.vo.AdminTopicVo;
import com.cskaoyan.service.AdminTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author chengyi
 * @date 2022/10/13 20:37
 */
@RestController //响应JSON数据
@RequestMapping("admin/topic")
public class AdminTopicController {
    @Autowired
    AdminTopicService adminTopicService;

    /**
     * 查找专题
     * @param info
     * @param title
     * @param subtitle
     * @return
     */
    @RequestMapping("list")
    public BaseRespVo list(BasePageInfo info, String title, String subtitle){
        CommonData<MarketTopic> data = adminTopicService.list(info,title,subtitle);
        return BaseRespVo.ok(data,"成功");
    }

    /**
     * 插入专题
     * @param marketTopic
     * @return
     */
    @RequestMapping("create")
    public BaseRespVo create(@RequestBody MarketTopic marketTopic){
        MarketTopic data = adminTopicService.create(marketTopic);
        return BaseRespVo.ok(data,"成功");
    }

    /**
     * 读取编辑信息
     * @param id
     * @return
     */
    @RequestMapping("read")
    public BaseRespVo read(Integer id){
        AdminTopicVo data = adminTopicService.read(id);
        return BaseRespVo.ok(data,"成功");
    }

    /**
     * 修改专题
     * @param marketTopic
     * @return
     */
    @RequestMapping("update")
    public BaseRespVo update(@RequestBody MarketTopic marketTopic){
        MarketTopic data = adminTopicService.update(marketTopic);
        return BaseRespVo.ok(data,"成功");
    }

    /**
     * 删除专题
     * @param marketTopic
     * @return
     */
    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody MarketTopic marketTopic){
        adminTopicService.delete(marketTopic);
        return BaseRespVo.ok("成功");
    }

    /**
     * 批量删除
     * @param
     * @return
     */
    @RequestMapping("batch-delete")
    public BaseRespVo batchDelete(@RequestBody Map map){
       adminTopicService.batchDelete(map);
        return BaseRespVo.ok("成功");
    }




}
